package com.lzh.controller;

import com.lzh.bean.Product;
import com.lzh.common.bean.PageBean;
import com.lzh.common.bean.ResultBean;
import com.lzh.common.controller.BaseController;
import com.lzh.query.ProductQuery;
import com.lzh.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
@Api(tags = "产品管理")
public class ProductController extends BaseController {

    @Autowired
    private ProductService productService;

    @PostMapping("/product/list")
    @ApiOperation("查询产品列表")
    public ResultBean queryProductList(@RequestBody ProductQuery productQuery){
        PageBean query = productService.query(productQuery);
        return success("产品列表",query);
    }


    @GetMapping("/product/{pid}")
    @ApiOperation("根据父id查询")
    public ResultBean queryProduct(@PathVariable("pid") Integer pid){
        List<Map> maps = productService.queryByPid(pid);
        return success("产品分类",maps);
    }
}
